package com.example.demo.controller;

import com.example.demo.entity.VO.chat.DialogueCriteriaVO;
import com.example.demo.entity.VO.chat.DialogueVO;
import com.example.demo.entity.VO.chat.MessageVO;
import com.example.demo.service.DialogueService;
import com.example.demo.utils.CommonConstant;
import com.example.demo.wrapper.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController
@RequestMapping("/api/v1")
public class dialogueController {

    private final DialogueService dialogueService;

    @Autowired
    public dialogueController(DialogueService dialogueService) {
        this.dialogueService = dialogueService;
    }


    @PostMapping("/message")
    public Result<DialogueVO> sendMessage(@RequestBody MessageVO messageVO){

        return Result.buildSuccess(dialogueService.sendMessage(messageVO));
    }


    @PostMapping("/dialogues")
    public Result<List<DialogueVO>> getDialogues(@RequestBody DialogueCriteriaVO dialogueCriteriaVO){

        dialogueCriteriaVO.setSize(CommonConstant.DIALOGUE_SIZE);
        return Result.buildSuccess(dialogueService.batchGetDialogue(dialogueCriteriaVO));
    }



}
